package fr.dauphine.td3.emp;

import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Version;

import org.hibernate.annotations.Proxy;

@Entity 
@Table(name="adresseProfessionnelle") 
@Proxy(lazy=false)
public class AdresseProfessionnelle extends AdressePersonnelle {
	
	String numeroBureau;
	int extensionTelephone;
	int fax;
	
	@Version
	long version;
	
	public AdresseProfessionnelle(String idEmploye, int numeroRue, String rue,
			int codePostal, String ville) {
		this(idEmploye, numeroRue, rue, codePostal, ville, 0, "", "", 0, 0);
		
	}
	
	public AdresseProfessionnelle(String idEmploye, int numeroRue, String rue,
			int codePostal, String ville, int telephone, String email, String numeroBureau, 
			int extensionTelephone, int fax) {
		super(idEmploye, numeroRue, rue, codePostal, ville, telephone, email);
		
		this.numeroBureau = numeroBureau;
		
		if (extensionTelephone != 0)
			this.extensionTelephone = extensionTelephone;
		
		if (fax != 0)
			this.fax = fax;
		
	}

	public String getNumeroBureau() {
		return numeroBureau;
	}

	public void setNumeroBureau(String numeroBureau) {
		this.numeroBureau = numeroBureau;
	}

	public int getExtensionTelephone() {
		return extensionTelephone;
	}

	public void setExtensionTelephone(int extensionTelephone) {
		this.extensionTelephone = extensionTelephone;
	}

	public int getFax() {
		return fax;
	}

	public void setFax(int fax) {
		this.fax = fax;
	}

	public long getVersion() {
		return version;
	}

	public void setVersion(long version) {
		this.version = version;
	}
	
	public int hashcode() {
		return idEmploye.hashCode();
	}
	
	@Override
	public String toString() {
		return "idEmploye: " + idEmploye + ";numeroRue: " + numeroRue + "; rue: " + rue
				+ ";code postal: " + codePostal + ";ville: " + ville + 
				";telephone: " + telephone + ";email: " + email
				+ ";numeroBureau: " + numeroBureau + ";extensionTelephone: " + extensionTelephone
				+ ";fax: " + fax;
	}
	
}
